const { contextBridge, ipcRenderer } = require('electron');

// 暴露安全的 API 给渲染进程
contextBridge.exposeInMainWorld('electronAPI', {
  // 选择文件夹
  selectFolder: () => ipcRenderer.invoke('select-folder'),
  
  // 扫描图片
  scanImages: (folderPath) => ipcRenderer.invoke('scan-images', folderPath),
  
  // 获取图片信息
  getImageInfo: (imagePath) => ipcRenderer.invoke('get-image-info', imagePath),
  
  // 监听主进程事件
  onFolderSelected: (callback) => {
    ipcRenderer.on('folder-selected', callback);
  },
  
  // 移除监听器
  removeAllListeners: (channel) => {
    ipcRenderer.removeAllListeners(channel);
  }
});
